package cn.uniquetech.hky;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class FileUtil {

	public static void writeFile(String packageName, String fileName, String content) {
		String filePath = GenerateCodeMysql.SAVEPATH+GenerateCodeMysql.DBNAME+"\\";
		String subpath = packageName.replace('.', '/');
		String dir = filePath + subpath;
		String fn = dir + "/" + fileName;
		try {
			File file = new File(dir);
			if (!file.exists()) {
				file.mkdirs();
			}
			file = new File(file, fileName);
			if (!file.exists()) {
				file.createNewFile();
			}
			FileWriter fw = new FileWriter(fn);
			PrintWriter pw = new PrintWriter(fw);
			pw.println(content);
			pw.flush();
			pw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
